﻿//-----------------------------------------------------------------------
// <copyright file="IRepository.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
//Code can be found in the GateShift project too: http://gateshift.codeplex.com
#region Usings

using System;
using System.Collections.Generic;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.Base;

#endregion

namespace FastNET.CleanAct.Common.Repository.Interfaces.Repositories.Base
{
    /// <summary>
    /// Base interface for all IData based repositories
    /// </summary>
    public interface IRepository
    {
    }

    /// <summary>
    /// Base interface for all repositories
    /// </summary>
    /// <typeparam name="D">IData the repository represents</typeparam>
    public interface IRepository<D>
        : IRepository
        where D : IData
    {
        /// <summary>
        /// Retrieves all instances of <typeparamref name="D"/> from the repository
        /// </summary>
        /// <returns>IEnumerable of the requested <typeparamref name="D"/></returns>
        IList<D> Retrieve();

        /// <summary>
        /// Deletes the requested <typeparamref name="D"/>
        /// </summary>
        /// <param name="Data">A <typeparamref name="D"/> to delete from the repository</param>
        /// <exception cref="ArgumentNullException">Thrown if data is null</exception>
        /// <exception cref="InvalidCastException">Thrown if the data is of the wrong type for this datasource</exception>
        /// <exception cref="InvalidOperationException">Thrown if the <typeparamref name="D"/> is new or already deleted</exception>
        void Delete(D Data);

        /// <summary>
        /// Saves the requested <typeparamref name="D"/>
        /// </summary>
        /// <param name="Data">A <typeparamref name="D"/> to save to the repository</param>
        /// <exception cref="ArgumentNullException">Thrown if data is null</exception>
        /// <exception cref="InvalidCastException">Thrown if the data is of the wrong type for this datasource</exception>
        void Save(D Data);

        /// <summary>
        /// Creates a new instance of <typeparamref name="D"/>
        /// </summary>
        /// <returns>New Instance of <typeparamref name="D"/></returns>
        D Create();
    }
}